package cz.muni.fi.pb138.gscholarinfo.classes;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Publication {
    //Cannot be null (always valid)
    private String title;
    private List<String> authors;
    private int citedTimes;
    
    //Can be 0 or null
    private int year;
    private String googleId;

    public Publication() {
        this.authors = new LinkedList<String>();
    }

    public List<String> getAuthors() {
        return Collections.unmodifiableList(authors);
    }

    public void addAuthor(String author) {
        this.authors.add(author);
    }

    public int getCitedTimes() {
        return citedTimes;
    }

    public void setCitedTimes(int citedTimes) {
        this.citedTimes = citedTimes;
    }

    public String getGoogleId() {
        return googleId;
    }

    public void setGoogleId(String googleId) {
        this.googleId = googleId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }
    
    @Override
    public String toString() {
        String ret = this.title + " - ";
        for (String item : this.authors)
            if (ret.charAt(ret.length()-2) == '-')
                ret += item;
            else
                ret += ", " + item;
        
        ret += "; " + this.year + "; cited " + this.citedTimes + " times; GID = " + this.googleId;
    
        return ret;
    }
}
